using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data {
    public partial class OrderItemMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<OrderItem> {
        public OrderItemMap() {
            // table
            ToTable("mc_OrderItem", "dbo");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.OrderId)
                .HasColumnName("OrderId")
                .IsRequired();
            Property(t => t.ProductId)
                .HasColumnName("ProductId")
                .IsOptional();
            Property(t => t.Quantity)
                .HasColumnName("Quantity")
                .IsRequired();
            Property(t => t.UnitPrice)
                .HasColumnName("UnitPrice")
                .HasPrecision(18, 2)
                .IsRequired();
            Property(t => t.MarketPrice)
                .HasColumnName("MarketPrice")
                .HasPrecision(18, 2)
                .IsRequired();
            Property(t => t.ProductName)
                .HasColumnName("ProductName")
                .HasMaxLength(200)
                .IsRequired();
            Property(t => t.ThumbnailsUrl)
                .HasColumnName("ThumbnailsUrl")
                .HasMaxLength(100)
                .IsOptional();
            Property(t => t.Integral)
                .HasColumnName("Integral")
                .IsOptional();
            Property(t => t.IntegralRate)
                .HasColumnName("IntegralRate")
                .IsOptional();
            Property(t => t.SkuName)
                .HasColumnName("SkuName")
                .IsOptional();
            Property(t => t.SkuPath)
                .HasColumnName("SkuPath")
                .IsOptional();
            Property(t => t.Body)
                .HasColumnName("Body")
                .IsOptional();
			Property(t => t.IsOpen)
                .HasColumnName("IsOpen")
				.IsRequired();
			Property(t => t.Points)
                .HasColumnName("Points")
				.IsRequired();
            Property(t => t.GrossWeight)
                .HasColumnName("GrossWeight")
                .IsOptional();
            Property(t => t.LegalWeight)
                .HasColumnName("LegalWeight")
                .IsOptional();

            Property(t => t.RedDrill)
              .HasPrecision(18, 6)
              .IsRequired();
            // Relationships
            HasRequired(t => t.Order)
                .WithMany(t => t.OrderItems)
                .HasForeignKey(d => d.OrderId)
                .WillCascadeOnDelete(false);
            HasRequired(t => t.Product)
                .WithMany()
                .HasForeignKey(d => d.ProductId)
                .WillCascadeOnDelete(false);
            HasRequired(t => t.TokenBazaarProduct)
                          .WithMany()
                          .HasForeignKey(d => d.BazaarProductId)
                          .WillCascadeOnDelete(false);
        }
    }
}
